package com.bobi.tfca.network.api

import com.bobi.tfca.network.response.MemberResponse
import com.bobi.tfca.network.response.LoginResponse
import com.bobi.tfca.network.response.BaseResponse
import com.bobi.tfca.network.response.MemberProfileResponse
import com.bobi.tfca.network.response.RoleResponse
import okhttp3.MultipartBody
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Path
import retrofit2.http.Query

interface MemberAPI {
    /**
     * 登录请求
     *
     * @param requestBody
     * @return
     */
    @Headers("Content-Type: application/json;charset=utf-8", "Accept: application/json")
    @POST("/login")
    fun login(@Body memberResponse: MemberResponse): Call<BaseResponse<LoginResponse>>

    /**
     * 查询会员
     */
    @Headers("Accept: application/json")
    @GET("/member/getMemberById/{memberId}")
    fun getMemberById(@Path("memberId") memberId: Int): Call<BaseResponse<MemberResponse>>

    /**
     * 移除协会成员
     */
    @Headers("Accept: application/json")
    @POST("/member/removeAssMember/{memberId}")
    fun removeAssMember(@Path("memberId") memberId: Int): Call<BaseResponse<String>>

    /**
     * 根据会员id查询会员档案
     */
    @Headers("Accept: application/json")
    @GET("/member/getProfileByMemberId/{memberId}")
    fun getProfileByMemberId(@Path("memberId")  memberId: Int): Call<BaseResponse<MemberProfileResponse>>

    /**
     * 查询所有在会成员
     */
    @Headers("Accept: application/json")
    @GET("/member/findAllStillMembers")
    fun findAllStillMembers(): Call<BaseResponse<ArrayList<MemberResponse>>>

    /**
     * 查询所有离会成员
     */
    @Headers("Accept: application/json")
    @GET("/member/findAllLeaveMembers")
    fun findAllLeaveMembers(): Call<BaseResponse<ArrayList<MemberResponse>>>

    /**
     * 根据名称查询在会会员
     */
    @Headers("Accept: application/json")
    @GET("/member/searchStillMemberByName")
    fun searchStillMemberByName(@Query("searchContent") searchContent: String): Call<BaseResponse<ArrayList<MemberResponse>>>

    /**
     * 根据名称查询退会会员
     */
    @Headers("Accept: application/json")
    @GET("/member/searchLeaveMemberByName")
    fun searchLeaveMemberByName(@Query("searchContent") searchContent: String): Call<BaseResponse<ArrayList<MemberResponse>>>

    /**
     * 修改密码
     */
    @Headers("Accept: application/json")
    @POST("/member/changePwByPw")
    @FormUrlEncoded
    fun changePwByPw(@Field("oldPassword") oldPassword: String, @Field("newPassword") newPassword: String): Call<BaseResponse<String>>

    /**
     * 找回密码
     */
    @Headers("Accept: application/json")
    @POST("/member/resetPassword")
    @FormUrlEncoded
    fun resetPassword(@Field("account") account: String, @Field("newPassword") newPassword: String, @Field("code") code: String): Call<BaseResponse<String>>

    /**
     * 注册会员
     */
    @Headers("Content-Type: application/json;charset=utf-8", "Accept: application/json")
    @POST("/member/registerMember")
    fun registerMember(@Body member: MemberProfileResponse, @Query("code") code: String): Call<BaseResponse<String>>

    /**
     * 查询全部角色
     */
    @Headers("Accept: application/json")
    @GET("/member/getAllRoles")
    fun getAllRoles() : Call<BaseResponse<ArrayList<RoleResponse>>>

    /**
     * 修改会员角色
     */
    @Headers("Accept: application/json")
    @POST("/member/changeMemberRole/{memberId}")
    fun changeMemberRole(@Path("memberId") memberId: Int, @Query("role") role: String): Call<BaseResponse<String>>

    /**
     * 查询会员页面元素
     */
    @Headers("Accept: application/json")
    @GET("/member/getMemberMenus")
    fun getMemberMenus() : Call<BaseResponse<ArrayList<String>>>

    /**
     * 登出
     */
    @Headers("Accept: application/json")
    @POST("/member/logout")
    fun logout(): Call<BaseResponse<String>>

    /**
     * 修改头像
     */
    @Multipart
    @POST("/member/updateMyHeadPhoto")
    fun updateMyHeadPhoto(@Part file: MultipartBody.Part): Call<BaseResponse<String>>

    /**
     * 查询是否存在该账号
     */
    @Headers("Accept: application/json")
    @GET("/member/getMemberByAccount")
    fun getMemberByAccount(@Query("account") account: String): Call<BaseResponse<String>>
}